//
//  NoticeCell.m
//  PropertyMananger
//
//  Created by Mansion on 16/12/24.
//  Copyright © 2016年 BH. All rights reserved.
//

#import "NoticeCell.h"
#import "MessageDetController.h"


@implementation NoticeCell




- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
+ (instancetype)cellWithTableView:(UITableView *)tableView
{

    static NSString *cellID = @"NoticeCellID";
    NoticeCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if(cell == nil) {
        cell = [[NoticeCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    //选中cell的颜色 -无色
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    [cell.advertScrollView removeFromSuperview];
    return cell;


}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.bgView = [[UIView alloc]init];
        //  self.bgView.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:self.bgView];
        
        [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(0);
            make.top.equalTo(self).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW, 35));
        }];
        
        //notice
        self.noticeImg = [[UIImageView alloc]init];
        [self.contentView addSubview:self.noticeImg];
        self.noticeImg.image = [UIImage imageNamed:@"ico_home_notice"];
        [self.noticeImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self.bgView).with.offset(8);
            make.centerY.equalTo(self.bgView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(20, 20));
        }];
        
        //标题
        self.titleLabel= [[UILabel alloc]init];
        [self.contentView addSubview:self.titleLabel];
        self.titleLabel.text = @"小区通知";
        self.titleLabel.font = [UIFont systemFontOfSize:13];
        self.titleLabel.textAlignment = NSTextAlignmentLeft;
        self.titleLabel.textColor = Theme_Color;
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.leading.equalTo(self.noticeImg).with.offset(20);
            make.top.equalTo(self.noticeImg).with.offset(-5);
            make.size.mas_equalTo(CGSizeMake(60, 30));
        }];
                
//        self.advertScrollView = [[SGAdvertScrollView alloc] init];
//        self.advertScrollView.frame = CGRectMake(85, 2, BHscreenW-90, 30);
//        self.advertScrollView.titleColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
////        self.advertScrollView.titleArray = @[@"", @"", @""];
//        self.advertScrollView.titleFont = [UIFont systemFontOfSize:15];
//        self.advertScrollView.advertScrollViewDelegate = self;
//        [self.contentView addSubview:self.advertScrollView];
    
        UIView * lineView = [[UIView alloc]init];
        [self addSubview:lineView];
        lineView.backgroundColor = BHColor(238, 238, 238);
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(0);
            make.top.equalTo(self.mas_bottom).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW, 10));
        }];
        

    }
    return self;
}
/// 代理方法
- (void)advertScrollView:(SGAdvertScrollView *)advertScrollView didSelectedItemAtIndex:(NSInteger)index {
    
    if (self.block) {
        
        self.block(index);
    }
}
- (void)setTitleArray:(NSMutableArray *)titleArray{
    NSMutableArray * messageArr = [[NSMutableArray alloc]init];
    
    for (MessageModel * model in titleArray) {
        
        [messageArr addObject:model.Title];
        
        
    }
    
    self.advertScrollView = [[SGAdvertScrollView alloc] init];
    self.advertScrollView.frame = CGRectMake(85, 2, BHscreenW-90, 30);
    self.advertScrollView.titleColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    self.advertScrollView.titleFont = [UIFont systemFontOfSize:15];
    self.advertScrollView.advertScrollViewDelegate = self;
    [self.contentView addSubview:self.advertScrollView];
     self.advertScrollView.titleArray = messageArr;
    DLog(@" === %ld",messageArr.count);

    
}

-(void)layoutSubviews{



}
@end
